package com.leanit.pmc.center.enterprise;

import com.leanit.pmc.common.dao.CommonDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 企业管理Controller
 */
@Service
public class EnterpriseService {

    @Autowired
    private CommonDao commonDao;

    @Autowired
    private EnterpriseDao enterpriseDao;

    @Transactional(readOnly = true)
    public EnterPriseInfo getEnterpriseInfo(String organizationId) {
        EnterPriseInfo enterPriseInfo = new EnterPriseInfo();
        enterPriseInfo.setOrganizationId(organizationId);
        return commonDao.qryOne("SYS_ENTERPRISE_INFO", enterPriseInfo, "");
    }

    @Transactional(readOnly = false)
    public boolean updateEnterpriseInfo(EnterPriseInfo enterPriseInfo) {
        return commonDao.updateCommonB("SYS_ENTERPRISE_INFO", enterPriseInfo, "WHERE ID = '1'");
    }

    @Transactional(readOnly = true)
    public EnterPriseInfo getBusinessBlob(String id, String type) {
        return enterpriseDao.getBusinessBlob(id, type + "_NAME", type + "_BLOB");
    }
}
